<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我是一阵风直播</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
    </style>
</head>
<body>
    <header class="aui-bar aui-bar-nav" id="aui-header">
        <div class="aui-title">正在直播</div>
    </header>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script>
    var aliyunLive;
    apiready = function () {
        var viewParm = api.pageParam;
        if(viewParm.rtmp_url == ''){
            viewParm.rtmp_url = 'rtmp://tuiliu.qiersan.com/9_30/30_3?auth_key=1582625851-0-0-acd3c1bd65a32fbcd2a36a0e48c804e6';
        }
        $api.fixStatusBar($api.byId('aui-header'));
        aliyunLive = api.require('aliyunLive');
        aliyunLive.configStream({
            rect: {
                x: 0,
                y: 0,
                w: auto,
                h: auto
            },
            url: viewParm.rtmp_url,
            bitRate: {
                videoMaxBitRate: 1500 * 1000,
                videoMinBitRate: 400 * 1000,
                videoBitRate: 600 * 1000,
                audioBitRate: 64 * 1000
            },
            fps: 20,
            screenOrientation: 'vertical',
            reconnectTimeout: 5,
            videoResolution: '240P',
            videoPreset: '1280*720',
            cameraPosition: 'front',
            waterMarkImage: {
                path: '',
                location: 'leftTop',
                maginX: 20,
                maginY: 20
            },
            fixed: true
        },function(ret) {
            startStream();
        });
    }
    // 增加连接状态监听
    function addConnectStatusListener() {
        aliyunLive.addConnectStatusListener(function(ret){
            alert(JSON.stringify(ret));
        });
    }
    // 销毁推流，测试有效
    function destroyStream() {
        aliyunLive.destroyStream();
    }
    // 转换摄像头,测试有效
    function toggleCamera() {
        aliyunLive.toggleCamera();
    }
    // 设置美颜,测试有效
    function setBeauty() {
        aliyunLive.setBeauty({
            beauty: 'on'
        });
    }
    // 设置静音
    function setMute() {
        aliyunLive.setMute({
            mute: 'on'
        });
    }
    // 设置闪光灯，测试有效，对后置摄像头有效
    function setFlash() {
        aliyunLive.setFlash({
            flash: 'on'
        });
    }
    // 停止推流
    function stopStream() {
        aliyunLive.stopStream(function(ret){
            alert(JSON.stringify(ret));
        });
    }
    // 开始推流
    function startStream() {
        aliyunLive.startStream(function(ret){
            alert(JSON.stringify(ret));
        });
    }
</script>
</html>
